GtkFontChooserWidget: Use a better display name for the font
authorBehdad Esfahbod <behdad@gnome.org>
Fri, 15 Aug 2014 17:27:00 +0000 (17:27 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 15 Aug 2014 18:12:10 +0000 (14:12 -0400)
Instead of reconstructing a display name from the
PangoFontDescription, use the font family and face
objects, which have the original font. This lets us
get the names of fonts like Noto Sans CJK DemiLight
right, which would be shown as Noto Sans CJK SemiLight
when mangled via PangoFontDescription, since Pango
treats 'DemiLight' as an alias for the SemiLight weight.

https://bugzilla.gnome.org/show_bug.cgi?id=733832

gtk/gtkfontchooserwidget.c

index c3fdf3d0353cc0ab4bc137ce5e2a962cf7870f5f..1edd2cd896e976f8353044f13c21c4df7bd6ece1 100644 (file)
@@ -770,16 +770,18 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
   GtkFontChooserWidget *fontchooser = user_data;
   PangoFontDescription *font_desc;
   PangoAttrList *attrs;
-  char *to_string, *text;
+  char *preview_title, *text;
   gsize first_line_len;
 
   font_desc = tree_model_get_font_description (tree_model, iter);
 
-  to_string = pango_font_description_to_string (font_desc);
+  gtk_tree_model_get (tree_model, iter,
+                      PREVIEW_TITLE_COLUMN, &preview_title,
+                      -1);
+
+  text = g_strconcat (preview_title, "\n", fontchooser->priv->preview_text, NULL);
+  first_line_len = strlen (preview_title) + 1;
 
-  text = g_strconcat (to_string, "\n", fontchooser->priv->preview_text, NULL);
-  first_line_len = strlen (to_string) + 1;
-  
   attrs = gtk_font_chooser_widget_get_preview_attributes (fontchooser, 
                                                           font_desc,
                                                           first_line_len);
@@ -791,7 +793,6 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
 
   pango_font_description_free (font_desc);
   pango_attr_list_unref (attrs);
-  g_free (to_string);
   g_free (text);
 }